package fr.umlv.rtsjtaskserver.server;

import javax.realtime.MemoryParameters;
import javax.realtime.PeriodicParameters;
import javax.realtime.PriorityParameters;
import javax.realtime.ProcessingGroupParameters;
import javax.realtime.RealtimeThread;
import javax.realtime.RelativeTime;
import javax.realtime.ReleaseParameters;
import javax.realtime.Schedulable;
import javax.realtime.Scheduler;
import javax.realtime.SchedulingParameters;

public class PollingServer extends TaskServer {

	private final static String POLICY = "PS";

	private final RealtimeThread thread;

	public PollingServer() {
		this.thread = new RealtimeThread(new PriorityParameters(
				RealtimeThread.MAX_PRIORITY), new PeriodicParameters(
				new RelativeTime(2000, 0))){
			
			@Override
			public void run() {
				do{
					PollingServer.this.getFollowingEvent();
					
				}
				while(RealtimeThread.waitForNextPeriod());
			}
		};
	}
	
	public ServableAsyncEventHandler getFollowingEvent(){
		
		ServableAsyncEventHandler saehl = this.getFollowingTask();  
		
	}

	@Override
	protected boolean addToFeasibility(Schedulable arg0) {
		// 
		return false;
	}

	@Override
	public void fireSchedulable(Schedulable arg0)
			throws UnsupportedOperationException {

	}

	@Override
	public String getPolicyName() {
		return POLICY;
	}

	@Override
	public boolean isFeasible() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	protected boolean removeFromFeasibility(Schedulable arg0) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean setIfFeasible(Schedulable arg0, ReleaseParameters arg1,
			MemoryParameters arg2) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean setIfFeasible(Schedulable arg0, ReleaseParameters arg1,
			MemoryParameters arg2, ProcessingGroupParameters arg3) {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean addIfFeasible() {
		return this.thread.addIfFeasible();
	}

	public boolean addToFeasibility() {
		return this.thread.addToFeasibility();
	}

	public MemoryParameters getMemoryParameters() {
		return this.thread.getMemoryParameters();
	}

	public ProcessingGroupParameters getProcessingGroupParameters() {
		return this.thread.getProcessingGroupParameters();
	}

	public ReleaseParameters getReleaseParameters() {
		return this.thread.getReleaseParameters();
	}

	public Scheduler getScheduler() {
		return this.thread.getScheduler();
	}

	public SchedulingParameters getSchedulingParameters() {
		return this.thread.getSchedulingParameters();
	}

	public boolean removeFromFeasibility() {
		return this.thread.removeFromFeasibility();
	}

	public boolean setIfFeasible(ReleaseParameters release, MemoryParameters memory) {
		return this.thread.setIfFeasible(release, memory);
	}

	public boolean setIfFeasible(ReleaseParameters release,
			ProcessingGroupParameters group) {
		return this.thread.setIfFeasible(release, group);
	}

	public boolean setIfFeasible(ReleaseParameters release, MemoryParameters memory,
			ProcessingGroupParameters group) {
		return this.thread.setIfFeasible(release, memory, group);
	}

	public boolean setIfFeasible(SchedulingParameters sched,
			ReleaseParameters release, MemoryParameters memory) {
		return this.thread.setIfFeasible(sched, release, memory);
	}

	public boolean setIfFeasible(SchedulingParameters sched,
			ReleaseParameters release, MemoryParameters memory,
			ProcessingGroupParameters group) {
		return this.thread.setIfFeasible(sched, release, memory, group);
	}

	public void setMemoryParameters(MemoryParameters memory) {
		this.thread.setMemoryParameters(memory);
	}

	public boolean setMemoryParametersIfFeasible(MemoryParameters memory) {
		return this.thread.setMemoryParametersIfFeasible(memory);
	}

	public void setProcessingGroupParameters(ProcessingGroupParameters group) {
		this.thread.setProcessingGroupParameters(group);
	}

	public boolean setProcessingGroupParametersIfFeasible(
			ProcessingGroupParameters group) {
		return this.thread.setProcessingGroupParametersIfFeasible(group);
	}

	public void setReleaseParameters(ReleaseParameters release) {
		this.thread.setReleaseParameters(release);
	}

	public boolean setReleaseParametersIfFeasible(ReleaseParameters release) {
		return this.thread.setReleaseParametersIfFeasible(release);
	}

	public void setScheduler(Scheduler scheduler) {
		this.thread.setScheduler(scheduler);
	}

	public void setScheduler(Scheduler scheduler, SchedulingParameters scheduling,
			ReleaseParameters release, MemoryParameters memory,
			ProcessingGroupParameters group) {
		this.thread.setScheduler(scheduler, scheduling, release, memory, group);
	}

	public void setSchedulingParameters(SchedulingParameters scheduling) {
		this.thread.setSchedulingParameters(scheduling);
	}

	public boolean setSchedulingParametersIfFeasible(SchedulingParameters scheduling) {
		return this.thread.setSchedulingParametersIfFeasible(scheduling);
	}

	public void run() {
		this.thread.run();
	}
}
